package com.bestvike.stone.spring.mail.bugreport;

import org.springframework.stereotype.Component;

/**
 * Created by 许崇雷 on 2017-11-21.
 */
@Component
public final class BugReportUtils {
    private static BugReportMailFactory bugReportMailFactory;
    private static BugReportThread bugReportThread;

    BugReportUtils(BugReportMailFactory bugReportMailFactoryInstance, BugReportThread bugReportThreadInstance) {
        bugReportMailFactory = bugReportMailFactoryInstance;
        bugReportThread = bugReportThreadInstance;
    }

    public static void sendAsync(BugReportLevel level, String content) {
        if (level == null)
            level = BugReportLevel.DEFAULT_LEVEL;
        bugReportThread.sendAsync(level, bugReportMailFactory.createMail(level, content));
    }
}
